<?php

namespace App\Api;

use App\Http\Controllers\Controller;
use App\Models\Menu;
use Illuminate\Http\Request;

class MenuController extends Controller
{

//获取所有初始化的节点
    public function getAllNodes()
    {
        $result = Menu::get()->toTree();
        return $result;
    }

//测试重建节点

    public function rebuildAllNodes(Request $request)
    {
//        return $request->data;
        $menus = Menu::create($request->data);

        return $this->message('重建成功', $menus);
    }

    //创建所有节点并初始化
    public function initNode()
    {
        $menus = include config_path() . '/menus.php';

        foreach ($menus as $key => $menu) {
            Menu::create($menu);
        }
        return $this->message('初始化成功');
    }

    //移动节点
    public function moveNode()
    {

    }

    //删除节点
    public function deleteNode()
    {

    }


}
